<?php
	$this->title = "打印预览页面";
?>
<style type="text/css" media="print">
	.table {margin-bottom: 0px;}
</style>


<div id="finance_print">
	<div class="col-md-6">
		<p>
			<h3 class="page-header" >收据 
				<button class="pull-right btn btn-primary btn-sm hidden-print" style="margin-left:15px;" onclick="financePrint()">打印收据</button>
				<button class="pull-right btn btn-info btn-sm hidden-print" onclick="location.reload()">刷新</button>
			</h3>
		</p>
		<table class="table table-bordered" style="margin-bottom: 0px;" >	
			<thead>
				<tr>
					<th colspan=2 class="text-center">基础信息</th>
				</tr>
			</thead>
	
			<tbody>
				<tr><td>单号</td><td><?= $model->code ?></td></tr>
				<tr><td>类型</td><td><?= Yii::$app->params['finance_type'][$model->type] ?></td></tr>
				<tr><td>支付方式</td><td><?= Yii::$app->params['finance_price_type'][$model->price_type] ?></td></tr>
				<tr><td>付款单位</td><td><?= $model->company ?></td></tr>
				<tr><td>付款账号</td><td><?= $model->account ?></td></tr>
				<tr><td>付款人姓名</td><td><?= $model->name ?></td></tr>
				<tr><td>描述</td><td><?= $model->desc ?></td></tr>
				<tr><td>状态</td><td><?= Yii::$app->params['finance_status'][$model->status] ?></td></tr>
				<tr><td>创建时间</td><td><?= Yii::$app->formatter->asDateTime($model->created_at) ?></td></tr>
				<tr><td>更新时间</td><td><?= Yii::$app->formatter->asDateTime($model->updated_at) ?></td></tr>
				<tr><td>总金额</td><td><?= Yii::$app->formatter->asCurrency($model->orderPrice) ?></td></tr>
	
				<tr><td colspan=2 >&nbsp;</td></tr>
	
			</tbody>
		</table>
	
	
		<table class="table table-bordered text-center"  style="margin-bottom: 0px;">	
			<tr><th colspan=3 class="text-center">收款明细</th></tr>
			<tr><td>团号</td><td>订单号码</td><td>金额</td></tr>
	
			<?php if($model->order) { 
					foreach($model->order as $order){	
			?>
						<tr>
							<td><?= $order->order->product->code ?></td>
							<td><?= $order->order->code ?></td>
							<td><?= Yii::$app->formatter->asCurrency($order->order->price) ?></td>
						</tr>
	
			<?php 	}	
				  } 
			?>
		</table>
		<div style="padding-top:30px;">
			<p class="pull-left">制单人: <?= $model->user->profile->name ?> </p>	
			<p class="pull-right">打印时间 : <?= date("Y-m-d H:i") ?> </p>	
		</div>
	</div>
</div>




<div id="invoice_print">
	<div class="col-md-6" >
		<p>
			<h3 class="page-header" >发票 
				<button class="pull-right btn btn-primary btn-sm hidden-print" style="margin-left:15px;" onclick="invoicePrint()">打印发票</button>
				<button class="pull-right btn btn-info btn-sm hidden-print" onclick="location.reload()">刷新</button>
			</h3>
		</p>
	
		<table class="table table-bordered"  style="margin-bottom: 0px;">
			<thead>
				<tr>
					<th colspan=2 class="text-center">基础信息</th>
				</tr>
			</thead>
	
			<tbody>
				<tr><td>单号</td><td><?= $model->code ?></td></tr>
				<tr><td>类型</td><td><?= Yii::$app->params['finance_type'][$model->type] ?></td></tr>
				<tr><td>支付方式</td><td><?= Yii::$app->params['finance_price_type'][$model->price_type] ?></td></tr>
				<tr><td>付款单位</td><td><?= $model->company ?></td></tr>
				<tr><td>付款账号</td><td><?= $model->account ?></td></tr>
				<tr><td>付款人姓名</td><td><?= $model->name ?></td></tr>
				<tr><td>描述</td><td><?= $model->desc ?></td></tr>
				<tr><td>状态</td><td><?= Yii::$app->params['finance_status'][$model->status] ?></td></tr>
				<tr><td>创建时间</td><td><?= Yii::$app->formatter->asDateTime($model->created_at) ?></td></tr>
				<tr><td>更新时间</td><td><?= Yii::$app->formatter->asDateTime($model->updated_at) ?></td></tr>
				<!-- tr><td>总金额</td><td></?= Yii::$app->formatter->asCurrency($model->invoiceOrderPrice) ?></td></tr -->
				<tr><td>总金额</td><td><?= Yii::$app->formatter->asCurrency($model->orderPrice) ?></td></tr>
	
				<tr><td colspan=2 >&nbsp;</td></tr>
			</tbody>
		</table>
	
		<table class="table table-bordered text-center"  style="margin-bottom: 0px;">
			<tr><th colspan=4 class="text-center">发票列表</th></tr>
			<tr><td>金额</td><td>抬头</td><td>项目</td><td>发票号码</td></tr>
	
			<?php if($model->invoice) {
					foreach($model->invoice as $invoice){
			?>
						<tr>
							<td><?= Yii::$app->formatter->asCurrency($invoice->OrderPrice) ?></td>
							<td><?= $invoice->company ?></td>
							<td><?= yii::$app->params['invoice_name'][$invoice->name] ?></td>
							<td><?= $invoice->code ?></td>
						</tr>
			<?php 	}
				  }
			?>
		</table>

		<div style="padding-top:30px;">
			<p class="pull-left">制单人: <?= $model->user->profile->name ?> </p>	
			<p class="pull-right">打印时间 : <?= date("Y-m-d H:i") ?> </p>	
		</div>
	</div>
</div>



<script>
    function financePrint(){
		document.body.innerHTML = document.getElementById('finance_print').innerHTML;
		window.print();
	}


    function invoicePrint(){
		document.body.innerHTML = document.getElementById('invoice_print').innerHTML;
		window.print();
	}
</script>
